package com.lovo.dao;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.lovo.po.User;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;

public interface UserDao extends BaseMapper<User> {

    @Select("SELECT * from t_user_role tur \n" +
            "INNER JOIN t_user tu on tu.user_id =tur.fk_user_id \n" +
            "INNER JOIN t_role tr on tr.role_id =tur.fk_role_id \n" +
            "INNER JOIN t_role_permission trp on trp.fk_role_id =tr.role_id \n" +
            "INNER JOIN t_permission tp on tp.permission_id =trp.fk_permission_id " +
            "${ew.customSqlSegment}")
    @ResultMap("com.lovo.dao.UserDao.userMap")
    User selectUserByWrapper(@Param(Constants.WRAPPER)Wrapper<User> wrapper);

}
